import os, cv2
from glob import glob
import SimpleITK as sitk
import numpy as np
from scipy.io import loadmat

# path_mat = r'G:\Desktop\USSeg\niis/4.mat'
# mat = loadmat(path_mat)
# print(mat.keys())

# print(mat['img3D'].shape)
# cv2.imshow('mat', mat['data'])
# cv2.waitKey(0)

# nii = sitk.ReadImage(r'G:\Desktop\USSeg\niis/48654.nii')
# nii = sitk.GetArrayFromImage(nii)
# print(nii.shape, nii.min(), nii.max())

nii = sitk.ReadImage(r'G:\Desktop\USSeg\data_label/152.nii')
nii_lab = sitk.ReadImage(r'G:\Desktop\USSeg\data_label/152-labels.nii')
nii = sitk.GetArrayFromImage(nii)[12]
nii_lab = sitk.GetArrayFromImage(nii_lab)[12]
lab = np.zeros_like(nii_lab, dtype=np.uint8)
lab[nii_lab==1] = 255

print(nii.shape, nii_lab.shape)
print(nii_lab.min(), nii_lab.max())
cv2.imshow('nii', nii)
cv2.imshow('lab', lab)
cv2.waitKey(0)